package CtrLayer;
import java.util.ArrayList;
import java.util.Date;

import DBLayer.OrderDB;
import ModelLayer.*;
public class OrderCtr {
	private CustomerCtr cCtr = new CustomerCtr();
	private SalesOrder order;
	private ProductCtr pCtr = new ProductCtr();
	

	public Customer findAndAddCustomer(String phoneno)
	{
		Customer customer = cCtr.findCustomer(phoneno);
		order = new SalesOrder(null,null,null,0, customer);
		return customer;
		
	}

	public void addProduct(String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int minStock, int stock, String productType, int supplierId)
	{
		pCtr.addProduct(name, purchasePrice, salesPrice, rentPrice, countryOfOrigin, minStock, stock, productType, supplierId);
	}
	
	public ArrayList<Clothing> findProductClothing(String productType)
	{
		return pCtr.findProductClothing(productType);
	}
	
	public ArrayList<Equipment> findProductEquipment(String productType)
	{
		return pCtr.findProductEquipment(productType);
	}
	
	public ArrayList<GunReplicas> findProductGunReplicas(String productType)
	{
		return pCtr.findProductGunReplicas(productType);
	}
	
	public void addProductToOrder(Product p, double amount)
	{
		PartOrder pO = new PartOrder(amount, p);
		order.addPartOrder(pO);
	}
	
	public void updateOrder(String deliveryStatus, Date deliveryDate)
	{
		Date date = new Date();
		
		order.setDate(date);
		order.setDeliveryStatus(deliveryStatus);
		order.setDeliveryDate(deliveryDate);
		
		
		OrderDB odb = new OrderDB();
		odb.addSalesOrder(order);
	}
}
